package com.akkainaction.router.group.actor.resizepool;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.routing.FromConfig;

public class MasterRouterActorByConf extends UntypedActor {
    //router就是一个actor
    ActorRef router;

    @Override
    public void preStart() {
        //配置文件的指定是在创建ActorSystem的时候指定的，FromConfig.getInstance()读取的就是ActorSystem加载的配置
        router = getContext().actorOf(FromConfig.getInstance().props(Props.create(TaskActor.class)), "taskActor");
        System.out.println("router:" + router);
    }

    @Override
    public void onReceive(Object msg) {
        router.tell(msg, getSender());
    }
}
